package com.text.day1_5.homework;

import java.util.Scanner;

public class Text {
    /**
     * 测试               不判断注册 登录 退出之间的逻辑关系
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        UserAct userAct = new UserAct();
        String userName;
        String passWord;
        while (true){
            System.out.println("请选择你要的功能：1.注册 \t 2.登录 \t 3.退出");
            String s = scanner.next();
            switch (s){
                case "1" :
                    System.out.println("注册");
                    System.out.println("请输入用户名");
                    userName = scanner.next();
                    System.out.println("请输入密码");
                    passWord = scanner.next();
                    switch (userAct.signUp(userName,passWord)) {
                        case 0:
                            System.out.println("注册成功");
                            break;
                        case 1:
                            System.out.println("用户名已存在");
                    }
                    break;
                case "2":
                    System.out.println("登录");
                    System.out.println("请输入用户名");
                    userName = scanner.next();
                    System.out.println("请输入密码");
                    passWord = scanner.next();
                    switch (userAct.logIn(userName,passWord)) {
                        case 0:
                            System.out.println("登录成功");
                            break;
                        case 1:
                            System.out.println("密码错误");
                            break;
                        case 2:
                            System.out.println("用户名错误");
                            break;
                        case 3:
                            System.out.println("用户已登录");
                    }
                    break;
                case "3":
                    System.out.println("退出");
                    System.out.println("请输入要退出的用户名");
                    userName = scanner.next();
                    switch (userAct.logOut(userName)) {
                        case 0:
                            System.out.println("退出成功");
                            break;
                        case 1:
                            System.out.println("用户已退出");
                            break;
                        case 2:
                            System.out.println("无此用户");
                    }
//                    System.out.println("退出，886");
//                    return;         退出此程序，并不是 退出登录

                    break;
                default:
                    System.out.println("输入错误");
            }
        }



    }
}
